/*
 * BinaryModOperatorAst.cpp
 *
 *  Created on: 5 Nov 2010
 *      Author: kn308
 */

#include <MAlice/Ast/BinaryModOperatorAst.h>

namespace MAlice
{

BinaryModOperatorAst::BinaryModOperatorAst(ExpressionAst* lhs,ExpressionAst* rhs):
			BinaryOperatorAst("%", lhs, rhs)
{
}

BinaryModOperatorAst::~BinaryModOperatorAst()
{
}

llvm::Value* BinaryModOperatorAst::generate()
{
	llvm::Value* LHS = getLHS()->generate();
	llvm::Value* RHS = getRHS()->generate();

	checkType(LHS, RHS);

	llvm::IRBuilder<>* builder = MAlice::Codegen::get()->getBuilder();

	return builder->CreateSRem(LHS, RHS);
}

}
